﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace XFControls
{
    public partial class XFLoginButton : UserControl
    {
        private Boolean Clicked;

        //flag to indicate the pressed state
        private System.ComponentModel.ComponentResourceManager Resources = new System.ComponentModel.ComponentResourceManager(typeof(XFLoginButton));

        public XFLoginButton()
        {
            InitializeComponent();
            ResetButton();
        }

        public void ResetButton()
        {
            this.picture.Image = ((System.Drawing.Image)(Resources.GetObject("lb_normal")));
            this.Invalidate();
        }

        //Events
        private void picture_Click(object sender, EventArgs e)
        {
            this.picture.Image = ((System.Drawing.Image)(Resources.GetObject("lb_logging")));
            this.picture.Invalidate();
            Clicked = true;

            //  Pass event on to control's OnClick method
            this.OnClick(e);
        }

        private void picture_MouseDown(object sender, MouseEventArgs e)
        {
            this.picture.Image = ((System.Drawing.Image)(Resources.GetObject("lb_pressed")));
            this.Invalidate();
        }

        private void picture_MouseUp(object sender, MouseEventArgs e)
        {
            if (!Clicked)
            {
                this.picture.Image = ((System.Drawing.Image)(Resources.GetObject("lb_normal")));
                this.Invalidate();
            }
            else
            {
                Clicked = false;
            }
        }
    }
}
